//
//  mainViewController.swift
//  股票框架
//
//  Created by 李小骥 on 2017/9/28.
//  Copyright © 2017年 李小骥. All rights reserved.
//

import UIKit
import WebKit
class mainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
//        状态栏白色
        UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
        //高亮色和默认色
        let highlightColor = Utils.kRGBColorFromHex(rgbValue: 0xF14F04)
        let unselectedColor = Utils.kRGBColorFromHex(rgbValue: 0x666666)
//        设置标题字体是白色
        //底部 tabbar 的字体色，选中色，背景色
        self.tabBar.tintColor = highlightColor
        self.tabBar.unselectedItemTintColor = unselectedColor
        self.tabBar.barTintColor = .white
        let selectedTitle = "选中"
        //首页及首页的导航控制器
        let homeVC = homeViewController(selfType: .home)
        let homeNaviVC = UINavigationController(rootViewController: homeVC)
        let homeTitle = "首页"
        homeVC.selfType = .home
        homeVC.navigationItem.title = homeTitle
        homeVC.tabBarItem.title = homeTitle
        homeVC.tabBarItem.image = UIImage(named: homeTitle)
        homeVC.tabBarItem.selectedImage = UIImage(named: homeTitle+selectedTitle)
        homeNaviVC.navigationBar.barTintColor = highlightColor
        homeNaviVC.navigationBar.titleTextAttributes = (naviBarTitleAttributes as! [NSAttributedStringKey : Any])
        //行情及行情的导航控制器
        let marketVC = MarketViewController()
        let marketNaviVC = UINavigationController(rootViewController: marketVC)
        let marketTitle = "行情"
        marketVC.navigationItem.title = marketTitle
        marketVC.tabBarItem.title = marketTitle
        marketVC.tabBarItem.image = UIImage(named: marketTitle)
        marketVC.tabBarItem.selectedImage = UIImage(named: marketTitle+selectedTitle)
        marketNaviVC.navigationBar.barTintColor = highlightColor
        marketNaviVC.navigationBar.titleTextAttributes = (naviBarTitleAttributes as! [NSAttributedStringKey : Any])
        //学院及学院的导航控制器
        let schoolVC = schoolViewController(selfType: .school)
        let schoolNaviVC = UINavigationController(rootViewController: schoolVC)
        let schoolTitle = "学院"
        schoolVC.selfType = .school
        schoolVC.navigationItem.title = schoolTitle
        schoolVC.tabBarItem.title = schoolTitle
        schoolVC.tabBarItem.image = UIImage(named: schoolTitle)
        schoolVC.tabBarItem.selectedImage = UIImage(named: schoolTitle+selectedTitle)
        schoolNaviVC.navigationBar.barTintColor = highlightColor
        schoolNaviVC.navigationBar.titleTextAttributes = (naviBarTitleAttributes as! [NSAttributedStringKey : Any])
        //直播及直播的导航控制器
        let broadcastVC = broadcastViewController(selfType: .broadcast)
        let broadcastNaviVC = UINavigationController(rootViewController: broadcastVC)
        let broadcastTitle = "直播"
        broadcastVC.selfType = .broadcast
        broadcastVC.navigationItem.title = broadcastTitle
        broadcastVC.tabBarItem.title = broadcastTitle
        broadcastVC.tabBarItem.image = UIImage(named: broadcastTitle)
        broadcastVC.tabBarItem.selectedImage = UIImage(named: broadcastTitle+selectedTitle)
        broadcastNaviVC.navigationBar.barTintColor = highlightColor
        broadcastNaviVC.navigationBar.titleTextAttributes = (naviBarTitleAttributes as! [NSAttributedStringKey : Any])
        //我的及我的的导航控制器
        let myVC = MyViewController()
        let myNaviVC = UINavigationController(rootViewController: myVC)
        let myTitle = "我的"
        myVC.navigationItem.title = myTitle
        myVC.tabBarItem.title = myTitle
        myVC.tabBarItem.image = UIImage(named: myTitle)
        myVC.tabBarItem.selectedImage = UIImage(named: myTitle+selectedTitle)
        myNaviVC.navigationBar.barTintColor = highlightColor
        myNaviVC.navigationBar.titleTextAttributes = (naviBarTitleAttributes as! [NSAttributedStringKey : Any])
        // Do any additional setup after loading the view.
        self.viewControllers = [homeNaviVC,marketNaviVC,schoolNaviVC,broadcastNaviVC,myNaviVC]
//        Utils.AlamofireAsynchronousGETTimeChartData(stockCode: "000030"){
//            print($0)
//        }

        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
